{% extends "base.html" %}

{% block title %}Vnos ocene izpita{% endblock %}

{% block js %}
<script type="text/javascript" src="{{ MEDIA_URL }}js/search.js"></script>
<script type="text/javascript">

$(document).ready(function(){    
    search_setcb('student', function(student){
      url = '/student/exam_result_paper/'+student.pk+'/';
      document.location = url;
    });
   
   
    id_subject_val = $("#id_subject").val();
    $("#id_subject").change(function(index,el){
      $("#id_subject").val(id_subject_val)
    });
   
/*   
    $("#id_rating_type").attr('disabled', "disabled");
    if ($("#id_rating_type").val() == 0){
      $(".errorlist").remove();
      subject_id = $("#id_subject").val();
      $.get("/exams/subject/rating_type/"+subject_id+"/", function(data){
        $("#id_rating_type").val(data.value);
      });
    }
*/

    $("#form_p").submit(function(){
      $("#id_rating_type").hide();
      $("#id_rating_type").removeAttr('disabled');
    
    });
    
    grade_type = '{{ app_obj.exam.rating_type }}';
    if (grade_type != 'OC1'){
      if (grade_type == 'OC2'){
        $("#id_exam_grade").parent().hide();
      } else if (grade_type == 'OC3'){
        $("#id_practice_grade").parent().hide();
      }
    }

});
</script>
{% endblock %}
{% block content %}


{% if only_search%}
 {% include "snippets/student/search.htm" %}
{% else %}

<script type="text/javascript">

$(document).ready(function(){


  $("#id_grade_date").datepicker({ maxDate: new Date() });
  $("#id_date").datepicker({ maxDate: new Date() });
  
  url = '{% url student_exam_result_paper_sel student.enrollment_number %}';
  $("#exams_list").change(function(){
    s_url = url+"?application="+$('#exams_list option:selected').val();
    document.location = s_url;
  });
  
  $("#subjects_list").change(function(){
    s_url = url+"?subject="+$('#subjects_list option:selected').val();
    document.location = s_url;
  });  
});

</script>

<form method="POST" id="form_p">
<p class="options_panel">
  <button onclick="search_show('student'); return false;">Poišči drugega študenta</button>
  {% if form %}
  <input type="submit" value="Shrani" />
  {% endif %}
</p>
 {% include "snippets/student/small_info.htm" %}
 <br />
<b>Izberi kako želiš vnesti oceno</b>
<p>
  <label>Prijavljeni izpiti študenta:</label>
 <select id="exams_list">
    <option value="0">Izberi izpit</option>
  {% for exam in exams%}
    <option {% if exam.pk == application %}selected="selected"{% endif %} value="{{ exam.pk }}"> {{ exam.exam }}</option>
  {% endfor %}
 </select>
</p>

<b>ali</b>

<p>
  <label>Vpisani predmeti študenta</label>
  <select id="subjects_list">
    <option value="0">Izberi predmet</option>
    {% for s in subjects %}
    <option {% if s.pk == subject %}selected="selected"{% endif %} value="{{ s.pk }}">{{ s }}</option>
    {% endfor %}
  </select>
</p>

 {% if application %}
  <h2>Vnos rezultatov za {{app_obj.exam.subject}} - {{ app_obj.exam.date }}</h2>
 {% csrf_token %}
 {{form.as_p}}
 <input type="submit" value="Shrani" />
 
 
 
 {% else %}
 
  {% if subject %}
    <h2>Vnos opravljanja izpita</h2>
    {% csrf_token %}
    {{  form.as_p }}
    <p>
      <label>Opravljanja do zdaj:</label> {{ tries }}
    </p>
    <input type="submit" value="Naslednji korak" />
  {% endif %}
 
 {% endif %}
</form>

{% endif %}


{% endblock %}>